using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Core.Mapping;


namespace WorldEditor
{
    public partial class WorldZoneGridItem : UserControl
    {
        public event EventHandler CreateZone;
        /// <summary>Get Zone</summary>
        public TileZone Zone { get { return _Zone; } }
        TileZone _Zone;
        Point _GridLocation;
        public event EventHandler Clicked;

        public WorldZoneGridItem(TileZone zone, Point gridxy )
        {
            _Zone = zone;
            _GridLocation = gridxy;
            InitializeComponent();
            SetButtonText();
        }

        protected void SetButtonText()
        {
            zoneSelect.Text = _Zone.Name + System.Environment.NewLine + 
                _Zone.WorldCoordinate.X.ToString() + "X" + _Zone.WorldCoordinate.Y.ToString();
        }

        private void zoneSelect_Click(object sender, EventArgs e)
        {
            //When Clicked send an event that includes the zones information
            if (Clicked != null)
                Clicked.Invoke(_Zone, e);
        }

        private void createZoneToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CreateZone != null)
            {
                CreateZone.Invoke(_GridLocation, null);
            }
        }
    }
}
